<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
	<base href="${pageContext.request.contextPath}/"></base>
	<title>毕业设计项目</title>
	<meta charset="utf-8">
	<link href="css/style.css" rel="stylesheet" type="text/css">
	<script type="text/javascript"  src="js/jquery-2.2.3.js"></script>
	<script src="script/common.js"></script>
	<script >
		$(function(){
            atvCustNo=$("#atvCustNo").val();
            atvCustName=$("#atvCustName").val();
            function QueryActivityById(atvId) {
                $.ajax({
                    type:"post",
                    url:"/CusterRelSys/CstActivity/queryActivityById",
                    data:atvId,
                    success:function(Activities){
						if(Activities!=null){
						    $("input[name=T1]").val(Activities.atvDate);
						    $("input[name=T2]").val(Activities.atvPlace);
						    $("input[name=T3]").val(Activities.atvTitle);
						    $("input[name=T4]").val(Activities.atvDesc);
						    $("textarea[name=s1]").text(Activities.atvRemark);
						}
                    },error:function(){

                    }
                });
            }
            atvID=$("#atvId").val();
            QueryActivityById({"atvId":atvID});

			function updateData() {
                var a= $("input[name=T1]").val().trim();
                var b=  $("input[name=T2]").val().trim();
                var c=  $("input[name=T3]").val().trim();
                var d= $("input[name=T4]").val()+"";
                var e=  $("textarea[name=s1]").text()+"";
                if(a=="" || a==null){
                    alert("日期必需填写")
                    return ;
				}else  if(b=="" || b==null){
                    console.log(333333333)
                    alert("地点必需填写")
                    return ;
                }else if (c=="" || c==null){
                    alert("概要必需填写")
                   
                }else{
                    updateActivity({"atvId":window.atvID,"atvDate":a,"atvPlace":b,"atvTitle":c,"atvDesc":d,"atvRemark":e})
				}


            };
			$("#saveActivity").click(function(){
                updateData();
			})
            function updateActivity(atvId) {
                $.ajax({
                    type:"post",
                    url:"/CusterRelSys/CstActivity/updateActivites",
                    data:atvId,
                    success:function(Activities){
                        if(Activities==1){
                            QueryActivityById({"atvId":window.atvID});
                            save('~cust/cust/activities.jsp?atvCustNo='+atvCustNo+"&atvCustName="+atvCustName);
						}else{
                            alert("保存失败")
						}

                    },error:function(){
                        alert("保存失败")
                    }
                });
            }
            QueryActivityById({"atvId":$("#atvId").val()});
            function saveActivity(atvId){
			}
		})
	</script>
</head>
<body>

<div class="page_title">客户信息管理 &gt; 客户信息 &gt; 交往记录 &gt; 编辑交往记录</div>
<div class="button_bar">
	<button class="common_button" onclick="help('');">帮助</button>
	<button class="common_button" onclick="back();">返回</button>
	<button class="common_button" id="saveActivity">保存</button><%--save('activities.jsp');--%>
</div>
<input type="hidden" id="atvId" value="<%=request.getParameter("atvId")%>">
<input type="hidden" id="atvCustNo" value="<%=request.getParameter("atvCustNo")%>">
<input type="hidden" id="atvCustName" value="<%=request.getParameter("atvCustName")%>">
<table class="query_form_table" id="table1">
	<tr>
		<th>时间</th>
		<td><input  name="T1" placeholder="yyyy-MM-dd" value="2007年10月09日" size="20" /><span class="red_star">*</span></td>
		<th>地点</th>
		<td>
			<input name="T2" value="友谊宾馆"  size="20" /><span class="red_star">*</span></td>
	</tr>
	<tr>
		<th>概要</th>
		<td><input name="T3"  value="签订意向协议" size="20" /><span class="red_star">*</span></td>
		<th>备注</th>
		<td><input name="T4" size="20" /></td>
	</tr>	
	<tr>
		<th>详细信息</th>
		<td colspan="3">
			<textarea cols="50" rows="6" name="S1">...</textarea>
		</td>
	</tr>
</table>
</body>
</html>